#ifndef _GEOMCYLINDER_
#define _GEOMCYLINDER_

#include "GeomObject.h"

// doesnt contain rotation
class GeomCylinder: public GeomObject{
protected:
	double mRadius;
	double mLowerRadius;
	double mLength;

	Vec3d mRotationXYZ;
	bool mFirstDraw;
public:
	// Constructor
	GeomCylinder(Vec3d _center, double _r, double _len) : mRadius(_r), mLength(_len){
		for(int i=0; i<3; i++) mTransform[i][3]=_center[i];
		mLowerRadius = _r;
		mType=CYLINDER;
		mRotationXYZ = Vec3d(-90, 0, 0);
		mFirstDraw=true;
	}
	// default oriented in Y direction due to rotation
	GeomCylinder(double _r, double _len) : mRadius(_r), mLength(_len){
		mLowerRadius = _r;
		mType=CYLINDER;
		mRotationXYZ = Vec3d(-90, 0, 0);
		mFirstDraw=true;
	}
	
	bool isInside(Vec3d _pt){
		//Vec3d _localPt = xform(getInvWorldTransform(), _pt);
		//return sqrlen((_pt)/(mRadii))<1;
		printf("Error in line %d in file %s: Not Yet Implemented!\n", __LINE__, __FILE__);
		return false;
	}
	// Get signed distance to inPoint
	inline double getSignedDist(const Vec3d &inPoint){
		printf("Error in line %d in file %s: Not Yet Implemented!\n", __LINE__, __FILE__);
		return 0;
	}
	double getVolume(){
		return M_PI*mRadius*mRadius*mLength;	//	Pi* r*r*h
	}

	void draw(Vec4d _col=Vec4d(vl_1), bool _default=true);

	inline double getRadius(){ return mRadius; }
	inline double getLength(){ return mLength; }
	void setExtent(Vec3d _d){
		mRadius=_d[0]/2;
		mLowerRadius = mRadius;
		mLength = _d[1];
		// d[2] is not used
	}
	void setLowerRadius(double _r){mLowerRadius=_r;}
	void setRotation(Vec3d _rotXYZ){mRotationXYZ = _rotXYZ;}
	Vec3d getOrientation();

	// Transform a plane by the inverse of inInverseMatrix
	GeomObject* getObjApplyInvTransform(const Mat4d &_mat);

};

#endif
